<script src="/assets/jstree-3.3.17/jstree.min.js"></script>
<link rel="stylesheet" href="/assets/jstree-3.3.17/themes/default/style.min.css"/>

<script type="text/javascript">
var tree;
$(function(){
	sajax({
        type: "POST",
        url: "/pisces/region/getData?enableFlag=${enableFlag}",
        dataType: 'json',
        success: function (data) {
        	for(var i=0;i<data.length;i++){
        		data[i].text = data[i].name;
        		if(data[i].parentId==-1){
        			data[i].parentId = '#';
        		}
        		data[i].parent = data[i].parentId;
        		data[i].state = {"opened": data[i].openFlag},
        		data[i].a_attr = {"type": data[i].type, "remark": data[i].remark, "zipCode": data[i].zipCode};
        	}
        	buildTree(data);
        	if(onTreeFinish){
        		onTreeFinish();
        	}
        }
    });
    
});

function buildTree(data){
	tree = $('#regionTree').jstree({
        'core': {
            'check_callback': true,
            'expand_selected_onload': true,
            'data': data
        }
    });
}

</script>
